package com.txby.test;

import org.springframework.web.client.RestTemplate;

public class RESTClient {
    private static RestTemplate template=new RestTemplate();
    
    private final static String url = "http://localhost:8090/rest/";
    
    public static String show() {
        return template.getForObject(url + "show", String.class, new String[]{});
    }
    
    public static String getUserById(String id) {
        return template.getForObject(url + "get/{id}", String.class, id); 
    }
    
    public static String addUser(String user) {
        return template.postForObject(url + "add?user={user}", null, String.class, user);
    }
    
    public static String editUser(String user) {
        template.put(url + "edit?user={user}", null, user);
        return user;
    }
    
    public static String removeUser(String id) {
        template.delete(url + "/remove/{id}", id);
        return id;
    }
    public static void main(String[] args) {
    	System.out.println(show());
    	
    	
    	
    	
//    	show();
//    	show();
//    	show();
	}
}